package cn.ibdsr.human.thread;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description 线程池
 * @Version V1.0
 * @CreateDate 2019/6/14 15:27
 *
 * Date                  Author               Description
 * ------------------------------------------------------
 * 2019-06-14 15:27:00   XuZhipeng               类说明
 *
 */
public class MyThreadPoolExecutor extends ThreadPoolExecutor {

    /**
     * 基本大小
     */
    private final static int CORE_POOL_SIZE = 5;

    /**
     * 最大线程数
     */
    private final static int MAXIMUM_POOL_SIZE = 10;

    /**
     * 生存时间
     */
    private final static long KEEP_ALIVE_TIME = 0L;

    public MyThreadPoolExecutor() {
        super(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(256),
                new ThreadFactoryBuilder().setNameFormat("demo-pool-%d").build(),
                new AbortPolicy());
    }

    public MyThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
                                long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
    }

}
